package sz.szsmk.citizencard.ui.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.model.network.bean.response.QueryCitizenCardRes;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/12/28 16:52
 * description:
 */
class AppcardItemAdapter extends RecyclerView.Adapter<AppcardItemAdapter.AppcarditemHolder> {

    private Context mContext;
    private List<QueryCitizenCardRes.CitizenCardInfoListBean.FunctionListBean> viewData;

    public AppcardItemAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public AppcarditemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.appcard_item, parent, false);
        return new AppcarditemHolder(view);
    }

    @Override
    public void onBindViewHolder(AppcarditemHolder holder, int position) {
        if (viewData!=null){
            holder.itemTv.setText(viewData.get(position).getFuncName());
        }
    }

    @Override
    public int getItemCount() {
        return null == viewData ? 0 : viewData.size();
    }

    public void setViewData(List<QueryCitizenCardRes.CitizenCardInfoListBean.FunctionListBean> viewData) {
        this.viewData = viewData;
    }


    public static class AppcarditemHolder extends RecyclerView.ViewHolder {

        private final TextView itemTv;

        public AppcarditemHolder(View itemView) {
            super(itemView);
            itemTv = (TextView) itemView.findViewById(R.id.appcard_item_tv);
        }
    }

}
